/** common.js  */
layui.define(['layer'], function(exports) {
	"use strict";

	var $ = layui.jquery,
		layer = layui.layer;

	var common = {
		/**
		 * 抛出一个异常错误信息
		 * @param {String} msg
		 */
		throwError: function(msg) {
			throw new Error(msg);
			return;
		},
		/**
		 * 弹出一个错误提示
		 * @param {String} msg
		 */
		msgError: function(msg) {
			layer.msg(msg, {
				icon: 5
			});
			return;
		},
		contextUrl: 'http://116.196.83.253:9001/',
		socketUrl: 'http://116.196.83.253:9000/',
	};

	$(document).ajaxError(function (event, xhr, settings) {
		//console.log("error=" + settings.url);
		layer.msg(xhr.responseJSON.msg);
	});
	$(document).ajaxSuccess(function (event, xhr, settings) {
		//console.log("success=" + settings.url);
		//console.log(xhr.responseJSON);
		if (!xhr.responseJSON.success) {
			layer.msg(xhr.responseJSON.msg);
		}
	});
	exports('common', common);
});